package com.ruoyi.zhjd.exp.modules.marshallrequires.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
// import com.qzsoft.jeemis.common.utils.Result;
//import com.qzsoft.jeemis.common.validator.ValidatorUtils;
// import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.ValidatorUtils;
import com.ruoyi.zhjd.exp.modules.marshallrequires.dto.MarshallRequiresDto;
import com.ruoyi.zhjd.exp.modules.marshallrequires.entity.MarshallRequiresEntity;
import com.ruoyi.zhjd.exp.modules.marshallrequires.service.MarshallRequiresService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author zhaij
 * @Description //马歇尔试验技术要求服务类
 * @Date 13:41 2021\11\26 0026
 * @Param
 * @return
 **/
@RestController
@RequestMapping("/api/marshallrequires/")
public class MarshallRequiresController {

    @Autowired
    private MarshallRequiresService marshallRequiresService;

    /**
     * @Title: page
     * @Description: 马歇尔技术要求分页列表
     * @param params 查询条件
     * @return Result 马歇尔技术要求分页列表
     */
    @GetMapping("page")
    public R<IPage<MarshallRequiresDto>> page(@RequestParam Map<String, Object> params) {
        IPage<MarshallRequiresDto> page = marshallRequiresService.page(params);
        return R.ok(page);
    }

    /**
     * @Title: save
     * @Description: 马歇尔技术要求新增
     * @param entity 查询条件
     * @return Result 马歇尔技术要求分页列表
     */
    @PostMapping("save")
    public R<String> save(@RequestBody MarshallRequiresEntity entity) {
        ValidatorUtils.validate(entity);
         marshallRequiresService.saveMarshallRequires(entity);
        return R.ok();
    }

    /**
     * @Title: detail
     * @Description: 马歇尔技术要求详情
     * @param id 查询条件
     * @return Result 马歇尔技术要求详情
     */
    @GetMapping("detail/{id}")
    public R<MarshallRequiresEntity> save(@PathVariable("id") String id) {
        MarshallRequiresEntity entity = marshallRequiresService.getById(id);
        return R.ok(entity);
    }

    /**
     * @Title: detail
     * @Description: 马歇尔技术要求详情
     * @param entity 查询条件
     * @return Result 马歇尔技术要求详情
     */
    @PostMapping("edit")
    public R<String> edit(@RequestBody MarshallRequiresEntity entity) {
        ValidatorUtils.validate(entity);
        marshallRequiresService.updateById(entity);
        return R.ok();
    }

    /**
     * @Title: detail
     * @Description: 马歇尔技术要求详情
     * @param id 查询条件
     * @return Result 马歇尔技术要求详情
     */
    @PostMapping("remove/{id}")
    public R<String> remove(@PathVariable("id") String id) {
        marshallRequiresService.removeById(id);
        return R.ok();
    }
}
